package cn.net.ecode.elec.api.web;

import cn.net.ecode.common.persistence.Page;
import cn.net.ecode.common.utils.StringUtils;
import cn.net.ecode.common.web.BaseController;
import cn.net.ecode.elec.entity.ElecAgencyBtype;
import cn.net.ecode.elec.entity.ElecAgencyDeal;
import cn.net.ecode.elec.entity.ElecAgencyDealDtl;
import cn.net.ecode.elec.service.ElecAgencyBtypeService;
import cn.net.ecode.elec.service.ElecAgencyDealDtlService;
import cn.net.ecode.elec.service.ElecAgencyDealService;
import cn.net.ecode.modules.cms.entity.Article;
import cn.net.ecode.modules.cms.entity.Category;
import cn.net.ecode.modules.cms.entity.Site;
import cn.net.ecode.modules.cms.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AppUserController
 * @Description 用户注册接口
 * @Author AlanShelby
 * @Date 2019/8/27 0027 8:43
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/agency/btype")
public class AppAgencyBtypeController extends BaseController {
    @Autowired
    private ElecAgencyBtypeService elecAgencyBtypeService;
    @Autowired
    private ElecAgencyDealService elecAgencyDealService;
    @Autowired
    private ElecAgencyDealDtlService elecAgencyDealDtlService;

    /**
     * 获取智慧能源  需求侧响应
     *
     * @param typeCode
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "elecAgencyBtypeList", method = RequestMethod.GET)
    public Page<ElecAgencyBtype> elecAgencyBtypeList(@RequestParam String typeCode, @RequestParam int pageNo, @RequestParam int pageSize) {
        if (!StringUtils.isBlank(typeCode)) {
            Page<ElecAgencyBtype> page = new Page();
            page.setPageNo(pageNo);
            page.setPageSize(pageSize);
            ElecAgencyBtype elecAgencyBtype = new ElecAgencyBtype();
            elecAgencyBtype.setTypeCode(typeCode);
            page = elecAgencyBtypeService.findPage(page, elecAgencyBtype);
            return page;
        } else {
            return new Page<>();
        }
    }

    /**
     * 获取智慧能源  需求侧响应 明细
     *
     * @param id 内容id
     * @return
     */
    @RequestMapping(value = "getElecAgencyBtype", method = RequestMethod.GET)
    public ElecAgencyBtype getElecAgencyBtype(@RequestParam String id) {
        if (StringUtils.isNotBlank(id)) {
            ElecAgencyBtype elecAgencyBtype = new ElecAgencyBtype();
            elecAgencyBtype.setId(id);
            elecAgencyBtype = elecAgencyBtypeService.get(elecAgencyBtype);
            return elecAgencyBtype;
        } else {
            return new ElecAgencyBtype();
        }
    }


    /**
     * 获取代理企业-电力交易
     *
     * @param typeCode
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "elecAgencyDealList", method = RequestMethod.GET)
    public Page<ElecAgencyDeal> elecAgencyDealList(@RequestParam String typeCode, @RequestParam int pageNo, @RequestParam int pageSize) {
        if (!StringUtils.isBlank(typeCode)) {
            Page<ElecAgencyDeal> page = new Page();
            page.setPageNo(pageNo);
            page.setPageSize(pageSize);
            ElecAgencyDeal elecAgencyDeal = new ElecAgencyDeal();
            elecAgencyDeal.setTypeCode(typeCode);
            page = elecAgencyDealService.findPage(page, elecAgencyDeal);
            return page;
        } else {
            return new Page<>();
        }
    }

    /**
     * 获取案例列表
     * @param sysId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "elecAgencyDealDtlList", method = RequestMethod.GET)
    public Page<ElecAgencyDealDtl> elecAgencyDealDtlList(@RequestParam String sysId, @RequestParam int pageNo, @RequestParam int pageSize) {
        Page<ElecAgencyDealDtl> page = new Page();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        ElecAgencyDealDtl elecAgencyDealDtl = new ElecAgencyDealDtl();
        elecAgencyDealDtl.setSysId(sysId);
        page = elecAgencyDealDtlService.findPage(page, elecAgencyDealDtl);
        return page;

    }

    /**
     * 获取案例明细
     * @param id
     * @return
     */
    @RequestMapping(value = "getElecAgencyDealDtl", method = RequestMethod.GET)
    public ElecAgencyDealDtl getElecAgencyDealDtl(@RequestParam String id) {
        if (StringUtils.isNotBlank(id)) {
            ElecAgencyDealDtl elecAgencyDealDtl = new ElecAgencyDealDtl();
            elecAgencyDealDtl.setId(id);
            elecAgencyDealDtl = elecAgencyDealDtlService.get(elecAgencyDealDtl);
            return elecAgencyDealDtl;
        } else {
            return new ElecAgencyDealDtl();
        }
    }
}
